extends Node2D

@export var message_label: Label

var message_list = []

const GAP_TIME = 1

func _ready():
	message_label.text = ""
	# add_message("Let's begin")
	# add_message("message test 1")
	# add_message("message test 2")

func add_message(message_text):
	message_list.append(message_text)
	try_next_message()

func try_next_message():
	if message_label.text == "":
		if len(message_list) != 0:
			message_label.text = message_list.pop_front()
			await get_tree().create_timer(GAP_TIME).timeout
			message_label.text = ""
			try_next_message()
		else:
			message_label.text = ""